package com.xjh.him.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import javax.validation.constraints.NotNull;

public class JSONUtil {
    /**
     * 序列化 null 字段
     * @param object
     * @return
     */
    public static String toJSONStringWithNull(@NotNull Object object) {
        return JSON.toJSONString(object,
                SerializerFeature.PrettyFormat,
                SerializerFeature.WriteNullNumberAsZero,
                SerializerFeature.WriteNullStringAsEmpty,
                SerializerFeature.WriteNullBooleanAsFalse,
                SerializerFeature.WriteNullListAsEmpty,
                SerializerFeature.WriteMapNullValue
        );
    }
}
